<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>

<script language="javascript">
    $(document).ready(function(){
        $("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){
               this.checked = checked_status;
            });
        });
    });
</script>
<?php //echo $javascript->link('jquery-1.4.2.js');?>
<?php echo $this->Form->create('HoaDonNhap',array('action'=>'admin_process')); ?>
<div class="head_title"><h1 align="center">DANH SÁCH HÓA ĐƠN NHẬP</h1></div>
<?php

    $nhvien = $this->Session->read('manhanvien');
    $mode = $this->Session->read('mode');
//echo $mode;
    ?>
<table>
    <tr>
		<th><?php echo $this->Form->checkbox('all',array('id'=>'checkall')); ?></th>
        <th><?php  echo $this->Paginator->sort('id', 'STT'); ?></th>

        <th><?php echo $this->Paginator->sort('MaNV', 'NHÂN VIÊN LẬP HÓA ĐƠN'); ?></th>
        <th><?php echo $this->Paginator->sort('MaCT', 'KHÁCH HÀNG'); ?></th>
        <th><?php echo $this->Paginator->sort('NgayNhap', 'NGÀY NHẬP'); ?></th>

        <th>THAY ĐỔI</th>
    </tr>

<?php foreach ($hoadonnhaps as $hoadonnhap): ?>
    <tr>
		<td><?php echo $this->Form->checkbox('HoaDonNhap.id.'.$hoadonnhap['HoaDonNhap']['id']); ?></td>
        <td><?php //echo $hoadonnhap['HoaDonNhap']['MaHDNhap'];
            //echo $this->Html->link($hoadonnhap['HoaDonNhap']['MaHDNhap'], array('controller' => 'nhaps',
            echo $this->Html->link($hoadonnhap['HoaDonNhap']['id'], array('action' => 'view', $hoadonnhap['HoaDonNhap']['id']), array('target' => '_blank'));                                                               //  'action' => 'index', $hoadonnhap['HoaDonNhap']['MaHDNhap']));
            ?></td>

    <td><?php echo $hoadonnhap['HoaDonNhap']['MANV']; ?></td>
    <!-- $this->Html->link($hanghoa['HangHoa']['TenHG'],
//    array('controller' => 'hanghoas', 'action' => 'view', $hanghoa['HangHoa']['TenHG'])) -->
    <td><?php echo $hoadonnhap['HoaDonNhap']['MAKH']; ?></td>
    <td><?php echo date('d-m-Y', strtotime($hoadonnhap['HoaDonNhap']['NGAYNHAP'])); ?></td>

        <td><?php
    if ($this->Session->read('quyen') != 'nhanvien') {
        echo $this->Html->link($this->Html->image('/images/user_edit.png'), array('action' => 'edit', $hoadonnhap['HoaDonNhap']['id']), array('escape' => false));
    } else echo '&nbsp';?>
    <?php if ($this->Session->read('quyen') == 'quantri') {
                echo $this->Html->link($this->Html->image('/images/trash.png'), array('action' => 'delete', $hoadonnhap['HoaDonNhap']['id']),
                    array('confirm' => 'Bạn có chắc muốn xóa?', 'escape' => false));}
        ?>
        </td>
    </tr>
    <?php endforeach        ; ?>
</table>

<?php
     echo $this->Form->end('Xóa các mục đã chọn', array('action' => 'Delete'));
?>

<div id="pagination">
    <div class="paging">
        <?php echo $this->Paginator->first('Trang đầu'); ?>
        <?php echo $this->Paginator->prev('<<' . __('Lùi', true),
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->numbers(); ?>
        <?php echo $this->Paginator->next(__('Tới', true) . '>>',
        array(), null, array('class' => 'disabled')); ?>
        <?php echo $this->Paginator->last('Trang cuối'); ?>
    </div>
</div>

    <?php
        echo $this->Html->link('Thêm hóa đơn nhập', array('controller' => 'hoa_don_nhaps', 'action' => 'add'), array('class' => 'add'));
        ?>
